package com.eastfair.tag.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.tag.enumeration.TagTypeEnum;
import com.eastfair.tag.enumeration.TagSelectTypeEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 标签表
 * </p>
 *
 * @author zjn
 * @since 2022-03-18
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tg_tag")
@ApiModel(value = "Tag", description = "标签表")
@AllArgsConstructor
public class Tag extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 项目ID
     */
    @ApiModelProperty(value = "项目ID")
    @NotNull(message = "请填写项目ID")
    @TableField(value = "project_id")
    @Excel(name = "项目ID")
    private Long projectId;

    /**
     * 类型父级ID
     */
    @ApiModelProperty(value = "类型父级ID")
    @NotNull(message = "请填写类型父级ID")
    @TableField(value = "parent_id")
    @Excel(name = "类型父级ID")
    private Long parentId;

    /**
     * 标签类型分级code
     */
    @ApiModelProperty(value = "标签类型分级code")
    @Size(max = 255, message = "标签类型分级code长度不能超过255")
    @TableField(value = "code", condition = LIKE)
    @Excel(name = "标签类型分级code")
    private String code;

    /**
     * 标签类型 #{classify:分类; node:标签}
     */
    @ApiModelProperty(value = "标签类型 #{classify:分类; node:标签}")
    @TableField(value = "type")
    @Excel(name = "标签类型 #{classify:分类; node:标签}", replace = {"分类_CLASSIFY", "标签_NODE",  "_null"})
    private TagTypeEnum type;

    /**
     * 标签分类（使用主体）
     */
    @ApiModelProperty(value = "标签分类（使用主体）")
    @Size(max = 255, message = "标签分类（使用主体）长度不能超过255")
    @TableField(value = "subject_type", condition = LIKE)
    @Excel(name = "标签分类（使用主体）")
    private String subjectType;

    /**
     * 标签名称
     */
    @ApiModelProperty(value = "标签名称")
    @Size(max = 255, message = "标签名称长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "标签名称")
    private String name;

    /**
     * 标签英文名称
     */
    @ApiModelProperty(value = "标签英文名称")
    @Size(max = 255, message = "标签英文名称长度不能超过255")
    @TableField(value = "en_name", condition = LIKE)
    @Excel(name = "标签英文名称")
    private String enName;

    /**
     * 权重值
     */
    @ApiModelProperty(value = "权重值")
    @TableField(value = "weight")
    @Excel(name = "权重值")
    private Integer weight;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 选择类型 #{simple:单选; multiple:多选}
     */
    @ApiModelProperty(value = "选择类型 #{simple:单选; multiple:多选}")
    @TableField(value = "select_type")
    @Excel(name = "选择类型 #{simple:单选; multiple:多选}", replace = {"单选_SIMPLE", "多选_MULTIPLE",  "_null"})
    private TagSelectTypeEnum selectType;

    /**
     * 最小选择数
     */
    @ApiModelProperty(value = "最小选择数")
    @TableField(value = "select_min_number")
    @Excel(name = "最小选择数")
    private Integer selectMinNumber;

    /**
     * 最大选择数
     */
    @ApiModelProperty(value = "最大选择数")
    @TableField(value = "select_max_number")
    @Excel(name = "最大选择数")
    private Integer selectMaxNumber;

    /**
     * 是否必选,0非必选，1必选
     */
    @ApiModelProperty(value = "是否必选,0非必选，1必选")
    @TableField(value = "is_required")
    @Excel(name = "是否必选,0非必选，1必选")
    private Integer isRequired;

    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;


    @Builder
    public Tag(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Long projectId, Long parentId, String code, TagTypeEnum type, String subjectType, 
                    String name, String enName, Integer weight, Integer sequence, TagSelectTypeEnum selectType, Integer selectMinNumber, 
                    Integer selectMaxNumber, Integer isRequired, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.projectId = projectId;
        this.parentId = parentId;
        this.code = code;
        this.type = type;
        this.subjectType = subjectType;
        this.name = name;
        this.enName = enName;
        this.weight = weight;
        this.sequence = sequence;
        this.selectType = selectType;
        this.selectMinNumber = selectMinNumber;
        this.selectMaxNumber = selectMaxNumber;
        this.isRequired = isRequired;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
